﻿<!DOCTYPE html>
@{
    Layout = "/Views/Shared/_level1.cshtml";
}
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta name="renderer" content="webkit">
    <link href="/SiteUI/Register/Register.css" rel="stylesheet" />
</head>
<body>
    <div class="view_fix" id="viewRegister">
        <div class="row" id="vr-tip">
            您正在申请重置登录密码
        </div>
        <div class="row">
            <div class="col-lg-4 col-lg-offset-4">
                <h5>原密码：</h5>
                <input type="password" maxlength="30" id="oldPwd" placeholder="请输入原密码" />

            </div>
            <div class="col-lg-4">
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-old"></div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-4 col-lg-offset-4">
                <h5>新密码：</h5>
                <input type="password" maxlength="30" id="newPwd" placeholder="请输入新密码" />
            </div>
            <div class="col-lg-4">
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-new"></div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-4 col-lg-offset-4">
                <h5>确认密码：</h5>
                <input type="password" maxlength="30" id="confirmPwd" placeholder="请输入确认密码" />

            </div>
            <div class="col-lg-4">
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-confirm"></div>
            </div>
            <div class="col-lg-4 col-lg-offset-4 button btn-big" id="btnResetPwd">
                重置密码
            </div>
        </div>
    </div>

    <script>
        var ResetPwd = {
            FormPwd: {
                oldPwd:null,
                newPwd:null,
                confirmPwd:null
            },
            oldPwdFormat:function(){
                var p = $("#oldPwd");
                if (p.val().length >= 6 && p.vl().indexOf(" ") == -1) {
                    $("#it-old").vl("").removeClass("error");
                    return true;
                } else {
                    $("#it-old").vl("密码至少为6位数").addClass("error");
                    return false;
                }
            },
            newPwdFormat: function () {
                var p = $("#newPwd");
                if (p.val().length >= 6 && p.vl().indexOf(" ") == -1) {
                    $("#it-new").vl("").removeClass("error");
                    return true;
                } else {
                    $("#it-new").vl("新密码至少为6位数").addClass("error");
                    return false;
                }
            },
            confirmPwdFormat: function () {
                var p = $("#confirmPwd");
                if (p.vl()== $("#newPwd").vl()&&p.vl().length>1) {
                    $("#it-confirm").vl("").removeClass("error");
                    return true;
                } else {
                    $("#it-confirm").vl("确定密码要和新密码一致").addClass("error");
                    return false;
                }
            },
            subPwdAlter: function () {
                if (ResetPwd.oldPwdFormat() && ResetPwd.newPwdFormat() && ResetPwd.confirmPwdFormat()) {
                    ResetPwd.FormPwd.oldPwd = $("#oldPwd").vl();
                    ResetPwd.FormPwd.newPwd = $("#newPwd").vl();
                    $("#btnResetPwd").off("click", ResetPwd.subPwdAlter);
                    $.post("/MyBiz/ChangePwd", ResetPwd.FormPwd, ResetPwd.subPwdAlterEnd);
                }
            },
            subPwdAlterEnd: function (rtn) {
                if (rtn.IsPositive) {
                    success("成功", "您的密码已修改，现在将返回之前的页面").on("disposed", function () { window.history.go(-1); });
                }
                else {
                    $("#btnResetPwd").on("click", ResetPwd.subPwdAlter);
                    error("失败", ErrFormate(res_sobiz, rtn.ErrorSrc, rtn.ErrorCode, rtn.Error));
                }
            }
        }
        $("#oldPwd").blur(ResetPwd.oldPwdFormat);
        $("#newPwd").blur(ResetPwd.newPwdFormat);
        $("#confirmPwd").blur(ResetPwd.confirmPwdFormat);
        $("#btnResetPwd").on("click", ResetPwd.subPwdAlter);
    </script>
</body>
</html>



